home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / SCHEME / GNU / SCM4E1 / !Scm / slib / mularg < prev    next >
Text File  |  1992-10-19  |  826b  |  27 lines

  1. ;;;; "multarg.scm" Redefine - and / to take more than 2 arguments.
  2. ;;; From: hugh@ear.mit.edu (Hugh Secker-Walker)
  3.  
  4. ;;; redefine / to take more than two arguments
  5. (define two-arg:/ /)
  6. (set! / (lambda (dividend . divisors)
  7.       (cond ((null? divisors) (two-arg:/ dividend))
  8.         ((null? (cdr divisors))
  9.          (two-arg:/ dividend (car divisors)))
  10.         (else 
  11.          (for-each (lambda (divisor)
  12.                  (set! dividend (two-arg:/ dividend divisor)))
  13.                divisors)
  14.          dividend))))
  15.  
  16. ;;; redefine - to take more than two arguments
  17. (define two-arg:- -)
  18. (set! - (lambda (minuend . subtrahends)
  19.       (cond ((null? subtrahends) (two-arg:- minuend))
  20.         ((null? (cdr subtrahends))
  21.          (two-arg:- minuend (car subtrahends)))
  22.         (else 
  23.          (for-each (lambda (subtrahend)
  24.                  (set! minuend (two-arg:- minuend subtrahend)))
  25.                subtrahends)
  26.          minuend))))
  27.